import React, { Component } from 'react'

export default class App extends Component {
  constructor(props){
    super(props);
    this.inputRef=React.createRef();
  }
  handelFocus=()=>{
    this.inputRef.current.focus();
  }
  render() {
    return (
      <div>
        <input type="text" ref={this.inputRef}/>
        <button onClick={this.handelFocus}>自动聚焦</button>
      </div>
    )
  }
}
